home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 26.zip / BS1 part 26 / mediaphile disk 3.adf / ARexx / toast_uni.rexx < prev   
OS/2 REXX Batch file  |  1991-06-07  |  2KB  |  58 lines

  1. /* toast_uni.rexx - a universal arexx script to send the command line */
  2. /* argument to the switcher program */
  3.  
  4. TRUE = 1
  5. FALSE = 0
  6. NULL = ""
  7.  
  8. /* Parse the command line arguments */
  9. parse arg arg1 arg2 arg3
  10.  
  11. /* Determine the number of passed arguments */
  12. noargs = 3      /* Do not want more than 3 */
  13. if arg3 = NULL then noargs = 2
  14. if arg2 = NULL then noargs = 1
  15. if arg1 = NULL then
  16.   do
  17.   SAY 'Need to pass a command line argument!'
  18.   exit
  19.   end
  20.  
  21. Switcher = 'ToasterARexx.port'    /* address Switcher's ARexx port */
  22. addlib(Switcher,0)
  23.  
  24. address command            /* otherwise unknown commands goto DOS */
  25.  
  26. if show(port,Switcher) = FALSE        /* if the Switcher is not around, */
  27. then                                /* load it                        */
  28.   do
  29.  
  30.   if arg(1) == "QUIT"               /* If this is a QUIT command, don't    */
  31.   then                              /* bother to load the switcher program */
  32.     do                              /* if it's not already in memory!      */
  33.     say 'Switcher is not loaded!'
  34.     exit
  35.   end
  36.  
  37.   say 'Loading switcher program...'
  38.   'Execute MP_ARexx:go_toast'  /* Perform dos functions */
  39.   address 'ARexxWait.port' 'wait'
  40.   end
  41.  
  42. address                /* disable DOS commands */
  43.  
  44. /* Make sure switcher program is activated (except for QUIT) */
  45. if arg1 ~= "QUIT" then Switcher(TOSW)        
  46.  
  47. /* Execute the command line argument (depends on no. of arguments) 
  48.    For some reason, arg3 is always preceded by a space, so chop it off
  49.    if we need to */
  50. if noargs = 1 then Switcher( arg1)
  51. if noargs = 2 then Switcher( arg1, arg2)
  52. if noargs = 3 then Switcher( arg1, arg2, RIGHT(arg3,(LENGTH(arg3)-1)) )
  53.  
  54. /* Put switcher program back to sleep (except for QUIT and TOSW) */
  55. if (arg1 ~= "QUIT") & (arg1 ~= "TOSW") then Switcher(TOWB)
  56.  
  57. exit
  58.